package main

import (
	"file_sys_server/model"
	"file_sys_server/server"
	"file_sys_server/utils"
	"fmt"
	"os"
)

func main() {
	// 连接数据库
	utils.LoadEnv()
	fmt.Println("load env...done")
	USER := os.Getenv("DB_USER")
	PASS := os.Getenv("DB_PASSWORD")
	HOST := os.Getenv("HOST")
	PORT := os.Getenv("DB_PORT")
	DBNAME := os.Getenv("DB_NAME")
	URL := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", USER, PASS,
		HOST, PORT, DBNAME)
	fmt.Println(URL)
	fmt.Println("connect mysql...")
	model.Database(URL)
	fmt.Println("connect done...")
	// 开启网络服务
	router := server.NewRouter()
	router.Run(":8088")
}
